package com.atguigu.composite;

import java.util.ArrayList;
import java.util.List;

//University就是Composite,可以管理College
public class University extends OrganizationComponent{

    List<OrganizationComponent> organizationComponentList = new ArrayList<OrganizationComponent>();

    //构造器
    public University(String name, String des) {
        super(name, des);
    }

    //重写add
    protected void add(OrganizationComponent organizationComponent){
        organizationComponentList.add(organizationComponent);
    }

    //重写remove
    protected void remove(OrganizationComponent organizationComponent){
        organizationComponentList.remove(organizationComponent);
    }


    @Override
    protected void print() {
        System.out.println("-------------------"+getName()+"-----------------");
        for (OrganizationComponent organizationComponent : organizationComponentList) {
            organizationComponent.print();
        }
    }
}
